package com.lb.action;

import java.util.Date;
import java.util.List;


import com.lb.bean.Message;
import com.lb.service.MessageService;
import com.opensymphony.xwork2.ActionSupport;
import java.text.SimpleDateFormat;

public class SaveMessageAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Message message;
	
	private MessageService service;

	private List<Message> messageshow;

	private String submittime;

	

	public List<Message> getMessageshow() {
		return messageshow;
	}

	public void setMessageshow(List<Message> messageshow) {
		this.messageshow = messageshow;
	}

	public String getSubmittime() {
		return submittime;
	}

	public void setSubmittime(String submittime) {
		this.submittime = submittime;
	}

	public Message getMessage() {
		return message;
	}

	public void setMessage(Message message) {
		this.message = message;
	}

	public MessageService getService() {
		return service;
	}

	public void setService(MessageService service) {
		this.service = service;
	}
	

     

	public String execute() throws Exception
	{ 
		
		Message message=new Message();
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	    String submittime= df.format(new Date());
	    message.setSubmitTime(submittime);
		message.setTitle(this.message.getTitle());
		message.setContent(this.message.getContent());
		message.setAccountName(this.message.getAccountName());
		this.service.save(message); 
	  
		messageshow=this.service.findmessageBymessageId(message.getMessageId());
		return SUCCESS;
	}


}
